package com.qfmy.model.entity.common;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * @author 清风明月
 * @Package com.qfmy.model.entity.userInfo
 * @date 2025/11/12
 * @description 用户订单实体类（映射数据库user_order表，包含余额/汀贝相关订单）
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserOrder {

    @Schema(description = "订单主键ID（自增，支持大数量订单）")
    private Long id;

    @Schema(description = "订单编号（业务唯一标识，格式如“OD2025111200001”）")
    private String orderNo;

    @Schema(description = "用户编号（关联用户表user_no字段，如“YX202500001”）")
    private String userNo;

    @Schema(description = "订单类型（1=余额订单，2=汀贝订单，区分业务场景）")
    private Integer orderType;

    @Schema(description = "交易类型（1=充值，2=提现，3=消费，4=赠送，标识具体操作）")
    private Integer tradeType;

    @Schema(description = "交易金额（仅余额订单有效，单位：元，保留2位小数）")
    private BigDecimal amount;

    @Schema(description = "交易数量（仅汀贝订单有效，单位：个，整数）")
    private Long quantity;

    @Schema(description = "订单状态（0=待处理，1=已完成，2=已取消，3=失败，跟踪订单生命周期）")
    private Integer status;

    @Schema(description = "订单描述（如“充值100元余额”“消费50个汀贝兑换商品”）")
    private String description;

    @Schema(description = "外部交易号（对接第三方支付时的平台单号，如微信支付单号，非必填）")
    private String outTradeNo;

    @Schema(description = "订单创建时间（精确到秒，用于订单时间排序）")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime createTime;

    @Schema(description = "订单更新时间（状态变更时自动更新，如“已完成”状态的时间）")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime updateTime;

    @Schema(description = "订单备注（如失败原因“余额不足”，非必填）")
    private String remark;
}